11. Exercise: ExoPlayer Event Listening

ExoPlayer Event Listening

Introduction

Now we have a customized media player that works perfectly for our app. The last step is to make it play well with external clients and other apps. But before we can set up a Media Session, we need to find out what the state of ExoPlayer is so that we can keep our Media Session in sync. We learned that state changes happen automatically with our SimpleExoPlayerView, but how are we going to get that information over to the Media Session? Go to the next video to find out!

ExoPlayer Event Listening

In this exercise, you'll monitor the state changes of the ExoPlayer using an EventListener, and log the state every time it changes.

Exercise Code

Exercise: TMED.03-Exercise-EventListening

Task List:

Task Feedback:

Status logged! Woot!

Solution: [TMED.03-Solution-EventListening][Diff]

ExoPlayer Event

In which method should you update the state of the MediaSession?

SOLUTION:
  • onPlayerStateChanged()